#include<iostream>
using namespace std;
int n, a[110] = {0};
bool v[110] = {false};

void dfs(int x) {
	if(x == n+1) {
		for(int i=1; i<n; i++)
			cout << a[i] << " ";
		cout << a[n] << endl;
		return;
	}
	for(int i=1; i<=n; i++) {
		if(!v[i]) {
			v[i] = true;
			a[x] = i;
			dfs(x+1);
			a[x] = 0;
			v[i] = false;
		}
	}
}

int main(){
	cin >> n;
	dfs(1);
	return 0;
}
